/**
 * @table: ${table.tableName}
 * @author : ${parametersConfig.author}
 * @date: ${date}
 * Code Generate By RateCode
 * Code Generate Gitee : https://gitee.com/GaopanL/rateCode
 */

package ${parametersConfig.packPath}.${module};

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.cglib.beans.BeanMap;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import ${parametersConfig.packPath}.common.core.domain.DataResponse;
import ${parametersConfig.packPath}.common.core.domain.TableData;
import ${parametersConfig.packPath}.model.system.${table.tableNameConverted};
import ${parametersConfig.packPath}.service.system.${table.tableNameConverted}Service;
import ${parametersConfig.packPath}.dao.system.${table.tableNameConverted}Dao;

@Service
public class ${table.tableNameConverted}Service{

    @Autowired
    private ${table.tableNameConverted}Dao ${table.tableNameHump}Dao;

    public DataResponse insert(${table.tableNameConverted} ${table.tableNameHump}){
        ${table.tableNameHump}Dao.insert(${table.tableNameHump});
        return DataResponse.ok("添加成功");
    }

    public TableData queryByPage(${table.tableNameConverted} ${table.tableNameHump}){
        Map<String,Object> map = new HashMap(BeanMap.create(${table.tableNameHump}));
        List<${table.tableNameConverted}> rows = ${table.tableNameHump}Dao.queryByPage(map);
        long total = ${table.tableNameHump}Dao.queryTotal(map);
        return new TableData(rows,total);
    }

    public DataResponse queryById(${table.fieldList[0].javaType} id){
        ${table.tableNameConverted} ${table.tableNameHump} = ${table.tableNameHump}Dao.queryById(id);
        return DataResponse.ok("查询成功",${table.tableNameHump});
    }

    public DataResponse update(${table.tableNameConverted} ${table.tableNameHump}){
        ${table.tableNameHump}Dao.update(${table.tableNameHump});
        return DataResponse.ok("修改成功");
    }

    public DataResponse deleteById(${table.fieldList[0].javaType} id){
        ${table.tableNameHump}Dao.deleteById(id);
        return DataResponse.ok("删除成功");
    }

}